package org.umlviewer.model.diagram_class;

import java.awt.Graphics;
import java.awt.Graphics2D;
import org.umlviewer.model.DiagramElement;
import org.umlviewer.model.Constants;
/**
 *
 * @author Rafa
 */
public class Package extends DiagramElement{
    
    //rectangulo superior
    private int wSup ;
    private int hSup = Constants.SHEIGHT * 2;
    //rectangulo inferior
    private int wInf;
    private int hInf = Constants.SHEIGHT * 4;

    public Package() {        
        setName("");
    }
    
    public Package(String name) {
        setName(name);
    }
        
    
    public void paint(Graphics g2) {
        Graphics2D g = (Graphics2D) g2;
        //rectangulo superior
        //ancho dependiendo del nombre
        wSup = getName().length() * Constants.SLETTER;
        g.drawRect(getPosX(), getPosY(), wSup, hSup);
        g.setFont(Constants.boldFont);
        g.drawString(getName(), getPosX()+5, getPosY()+15);
        g.setFont(Constants.defaultFont);
        //parte inferior
        wInf = wSup + 20;
        g.drawRect(getPosX(), getPosY()+hSup, wInf, hInf);
        setWidth(wInf);
        setHeight(hSup+hInf);
    }
    
}
